(function($)
{
    $.fn.customFileUpload = function()
    {
        return this.each(function(){    
            $(this).css('position', 'relative');
            $(this).html('<div style="position: absolute; z-index: 1; left: 0; top: 0;">' + $(this).html() + '</div>');
            
            $(this).prepend('<input type="file" style="position: relative; filter: alpha(opacity=0); opacity: 0; ' +
                'width: ' + $(this).attr('clientWidth') + 'px; z-index: 5" />');

            var fl = $(this).find('input[type="file"]:first');            
            var txt = $(this).find('input[type="text"]');            
            fl.change(function() {txt.attr('value', this.value);});
            fl.mouseout(function() {if (this.value) txt.attr('value', this.value);});         
        });
    };
}
)(jQuery);
